// cd25 [暴力法/最长上升子序列] 最长递增子序列
// https://www.nowcoder.com/practice/30fb9b3cab9742ecae9acda1c75bf927
// LIS(Longest Increasing Subsequence)
#include <stdio.h>
#include <stdlib.h>

#include <string>
#include <vector>
using namespace std;

int lengthOfLIS(std::vector<int>& nums) {
  if (nums.size() == 0) return 0;
  int n = nums.size();
  int res = 1;
  std::vector<int> lvct(n);
  lvct[0] = 1;
  //填充L
  for (int i = 1; i < n; i++) {
    int maxval = 1;
    //遍历所有的A
    for (int j = 0; j < i; j++) {
      if (nums[i] > nums[j]) {
        maxval = std::max(maxval, lvct[j] + 1);
      }
      lvct[i] = maxval;
    }
  }
  for (int i = 0; i < n; i++) {
    if (lvct[i] > res) {
      res = lvct[i];
    }
  }
  return res;
}
int main1() {
  int a;
  while (scanf("%d", &a) != EOF) {
    std::vector<int> avct;
    for (int i = 0; i < a; i++) {
      int n = 0;
      scanf("%d", &n);
      avct.push_back(n);
    }
    printf("%d\n", lengthOfLIS(avct));
  }
  return 0;
}
